package spring.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description：
 * @author：涂有
 * @date 2015年11月8日 下午10:50:33
 */
public class PersonService {

	private String name;
	
	public void setName(String name){
		
		this.name = name;
	}
	
	public void info(){
		
		System.out.println("此人名为：" + name);
	}
	
	public static void main(String[] args) {

		ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		
		//通过类型获得实例
		PersonService ps = context.getBean(PersonService.class);
		ps.info();
		
		//通过bean名称获得实例
		PersonService ps2 = (PersonService)context.getBean("personService");
		ps2.info();
		
	}
}
